package com.object;

/**
 * @author xiangui
 * 描述:
 * 时间: Create in 8:59 2018/7/20
 */

interface HasBatteries{};

interface WaterProof{};

interface Shoots{};

class Toy{
    Toy() {
    }
    Toy(int i){}
}

class FancyToy extends Toy implements HasBatteries, WaterProof, Shoots{
    FancyToy(){super(1);}
}

public class ToyTest {

    static void printInfo(Class cc){
        System.out.println("Class Name:" + cc.getName() + "is interface? [" + cc.isInterface() + "]");

        System.out.println("Simple name:" + cc.getSimpleName());

        System.out.println("Canonical name :" + cc.getCanonicalName());

    }

    public static void main(String[] args) {
        Class c = null;
        try {
            c = Class.forName("com.object.FancyToy");
        } catch (ClassNotFoundException e) {
            System.out.println("Couldn't find FancyToy");
            System.exit(1);
        }
        printInfo(c);
        for(Class face : c.getInterfaces()){
            printInfo(face);
        }
        Class up = c.getSuperclass();
        Object obj = null;
        try {
            obj = up.newInstance();
        } catch (InstantiationException e) {
            System.out.println("Can not interface");
            System.exit(1);
        } catch (IllegalAccessException e) {
            System.out.println("Can not access");
            System.exit(1);
        }
        printInfo(obj.getClass());


    }


}
